<?

extract($_POST);
extract($_GET);
	include 'conexion.php';
        //$base= "ucg - copia";
		$tabla = "compra1";
	//$conexion=mysql_connect("localhost","root","");
	//mysql_select_db($base,$conexion);
	$resultado=mysql_query("SELECT * FROM $tabla WHERE cod_c='$Modificar'",$conexion);
	$registro = mysql_fetch_row($resultado);?>
    
    
    <title>Consulta Compras</title>
 <style type="text/css">
<!--
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #000000;
}
body {
	background-color: #FFFFFF;
}
a {
	font-family: Courier New, Courier, mono;
	font-size: 14px;
	color: #000000;
}
a:visited {
	color: #000000;
}
a:hover {
	color: #000000;
}
a:active {
	color: #999999;
}
-->
 </style>

<style type="text/css">
<!--
@import url("tablas.css");
a:link {
	color: #000000;
}
.style5 {
	font-size: 14px;
	font-weight: bold;
	color: #000000;
}
.style9 {
	color: #000000;
	font-weight: bold;
}
.style4 {font-size: 12px}
.style12 {font-size: 14px; color: #000000; }
.Estilo1 {font-size: xx-small}
.Estilo3 {font-size: 10; }
-->
</style>
<table width="100%" border="1" class="celdatodo">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
  <tr>
    <td colspan="3">Fecha:</td>
    <td colspan="4" ><? echo "$registro[3]";?></td>
  </tr>
  <tr>
  <? if ($registro[2]==1) $tipo="DE COMPRA";
     if ($registro[2]==2) $tipo="DE SERVICIO";
	 if ($registro[2]==3) $tipo="INTERNA"; ?>
  
    <td height="21" colspan="7">Mediante la presente se emite <strong>ORDEN <? echo $tipo ?></strong> interna a la empresa </td>
  </tr>
  <tr>
    <td colspan="3"><strong>Empresa:</strong></td>
    <? $resul=mysql_query("SELECT emp FROM proveedor WHERE rif='$registro[4]'",$conexion);

	$regis = mysql_fetch_row($resul); ?>
    <td colspan="4"><? echo "$regis[0]";?></td>
  </tr>
  <tr>
    <td colspan="3"><strong>Rif:</strong></td>
    <td colspan="4"><? echo "$registro[4]";?></td>
  </tr>
  
  <tr>
    <td width="6%" height="27"><div align="center" class="Estilo1"><strong>Cantidad</strong></div></td>
    <td colspan="2"><div align="center" class="Estilo1"><strong>Cuenta Usada</strong></div></td>
    <td colspan="2"><div align="center" class="Estilo1"><strong>Descripci&oacute;n</strong></div></td>
    <td width="9%"><div align="center" class="Estilo1"><strong>Precio Unitario </strong></div>
      <div align="center">
      <div align="center" class="Estilo1"></div></td>
    <td width="8%"><div align="center" class="Estilo1"><strong>Total</strong></div></td>
  </tr>
  <? $resu=mysql_query("SELECT * FROM  id_compra WHERE cod_c='$registro[0]'",$conexion);

	while ($reg= mysql_fetch_row($resu)) { 	?>
  <tr bordercolor="#000000">
    <td align="center">
	
	  <span class="Estilo1">
	  <? 
	if ($tipo=="INTERNA"){ $cant=round($reg[2],4);}	
	else {
	$cant=round($reg[2],2);} 
	echo $cant; ?></span></td>
    
    <td colspan="2" align="center">
      <span class="Estilo1">
      <?
	$sqlcu="Select * from cuenta_gen where cuenta='$reg[5]'";
	$resulcu = mysql_query($sqlcu, $conexion);
	$cue = mysql_fetch_array($resulcu);
	
	 echo $cue[1];?>
      .</span></td>
    <td colspan="2">
	  <span class="Estilo1"><? echo "$reg[3]";?></span> </td>
    <td align="right" valign="middle"> 
      <span class="Estilo1">
      <? 
	if ($tipo=="INTERNA"){ $uni= number_format($reg[4],4,",","."); }	
	else {
	$uni= number_format($reg[4],2,",",".");	}
	echo $uni; ?>
    </span> </td>
    <td align="right" valign="middle">
	
	  <span class="Estilo1">
	  <? $totaluni=$reg[2]*$reg[4]; 
	
	if ($tipo=="INTERNA"){ $totaluni1= number_format($totaluni,4,",","."); }	
	else {
	$totaluni1= number_format($totaluni,2,",",".");}
	echo $totaluni1; ?>
    </span></td>
  </tr>
  <? $subtotal=$subtotal+$totaluni; } ?>
  <tr>
    <td colspan="5" class="celdatodo"></td>
    <td ><div align="right" class="Estilo1">SUB - TOTAL</div></td>
    <td align="right" valign="middle" bordercolor="#000000">
      <span class="Estilo1">
      <?
	  if ($tipo=="INTERNA"){ $subtotal1= number_format($subtotal,4,",","."); }	
	else {  
	  $subtotal1= number_format($subtotal,2,",",".");}
	  echo $subtotal1; ?>
      </span> </td>
  </tr>
  <? 
  
  
  $re=mysql_query("SELECT sum(valor_iva),iva FROM  id_compra WHERE cod_c='$registro[0]' and iva!='0' group by iva",$conexion);

	while ($iva= mysql_fetch_row($re)) { 
	
	?>
  <tr>
    <td colspan="5" ></td>
    <td ><div align="right" class="Estilo1">IVA <? echo "$iva[1]";?> %</div></td>
    <td align="right" valign="middle" bordercolor="#000000">
      <span class="Estilo1">
      <? $totaliva=$iva[0];
	  
	  if ($tipo=="INTERNA"){ $totalivat= number_format($totaliva,4,",","."); }	
	else {
	   $totalivat= number_format($totaliva,2,",",".");}
	  echo $totalivat; ?>
      </span> </td>
  </tr>
  <? $totaliva1=$totaliva1+$totaliva; 
  // $totaliva2= number_format($totaliva1,2,",",".");
  } ?>
  <tr>
    <td colspan="5" ></td>
    <td ><div align="right" class="Estilo1"><strong>TOTAL BsF.</strong></div></td>
    <td align="right" valign="middle" bordercolor="#000000" >
      <span class="Estilo1">
      <? 
	  $total=$subtotal+$totaliva;
	  if ($tipo=="INTERNA"){  $total1= number_format($total,4,",","."); }	
	else {	  
	  $total1= number_format($total,2,",",".");}
	  echo $total1; ?>
      </span> </td>
  </tr>
<tr>
    <td height="28" colspan="2" class="celdatodo" ><div align="center" class="style4">Elaborado Por: </div></td>
    <td colspan="2" class="celdatodo" ><div align="center" class="style4">Revisado por:</div></td>
    <td width="26%" class="celdatodo"><div align="center" class="style4">Aprobado Por: </div></td>
    <td colspan="2" class="celdatodo" ><div align="center" class="Estilo1">Recibido Por: </div></td>
  </tr>
  <tr>
    <td colspan="7" class="celdatodo" >&nbsp;</td>
  </tr>
  <tr>
    <td colspan="7" class="celdatodo" ><div align="center"></div>      <div align="center"></div>      <div align="center"></div></td>
  </tr>
  <tr>
    <td colspan="2" class="celdatodo"><div align="center" class="Estilo3"><? echo "$registro[10]";?></div></td>
    <td colspan="2" class="celdatodo"><div align="center" class="Estilo3"><? echo "$registro[6]";?></div></td>
    <td class="celdatodo"><div align="center" class="Estilo3"><? echo "$registro[7]";?></div></td>
    <td colspan="2" class="celdatodo"><div align="center" class="Estilo3">&nbsp;</div></td>
  </tr>
  <tr>
    <td colspan="2" class="celdatodo"><div align="center" class="Estilo3">Asistente Administrativo</div></td>
    <td colspan="2" class="celdatodo"><div align="center" class="Estilo3">Administradora de la Unidad </div></td>
    <td class="celdatodo"><div align="center" class="Estilo3">Jefe de la Unidad </div></td>
    <td colspan="2" class="celdatodo"><div align="center">Firma y Sello    </div></td>
  </tr>
</table>





